const { list, product } = require("./mock");
const bodyParser = require("body-parser");
module.exports = (app) => {
  app.get("/api/list", (req, res) => {
    res.send({
      code: 200,
      data: list,
    });
  });

  app.get("/api/product", (req, res) => {
    res.send({
      code: 200,
      data: product,
    });
  });

  app.get("/api/detail", (req, res) => {
    const { id } = req.query;
    product.forEach((v) => {
      const result = v.children.find((v) => v.id === id);
      if (result) {
        res.send({
          code: 200,
          data: result,
        });
      }
    });
  });
};
